package com.maven.front.service.eduUser;


import com.maven.front.bean.EduUser;
import com.maven.front.bean.Result;
import com.maven.front.mapper.EduUserMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Slf4j
@Service
public class EduUserService {



    @Resource
    private EduUserMapper eduUserMapper;

    public List<EduUser> list(){
        List<EduUser> list=eduUserMapper.select(null);
        //判断集合是否为空
        if (CollectionUtils.isEmpty(list)){
            return null;
        }else {
            return list;
        }
    }

public EduUser getid1(Integer id){
        return eduUserMapper.getid(id);
}

    //根据id查询,返回页面
    public Result getid(String id){
        String [] arr = id.split(",");
        List<EduUser> list = new ArrayList<>();
        for (int i=0; i<arr.length; i++){
            log.info(arr[i]);
            EduUser eduUser = new EduUser();
            if(arr[i]!=null){
                eduUser =eduUserMapper.getid(Integer.valueOf(arr[i]));
                list.add(eduUser);
            }
        }
        if (CollectionUtils.isEmpty(list)){
            return new Result(10005, "查询失败！", null);
        } else {
            return new Result(200, "查询成功！", list);
        }
    }
}
